package tcp;

import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Date;

public class NovaThread extends Thread {

    private Socket socket;

    public NovaThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            //fluxo de sa�da
            BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());
            PrintWriter os = new PrintWriter(bos, false);

            while (true) {
                Date now = new Date();
                os.println(now);
                os.flush();

                Thread.sleep(1000);

                os.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
